package com.enjoy.xbase.sort.model;

import android.view.View;

import androidx.annotation.DrawableRes;

public class TabMenu {

    private int type;// 0-非排序(跳转外部) 1-单选 2-双向可选 3-下拉筛选
    private int order;// 0-未选中 1-升 2 -降
    private int defaultOrder;//默认排序方式 1-升 2 -降
    private String name;

    //只针对跳转
    private int iconResId;//跳转类型辅助图标
    private int pos;//跳转类型辅助图标位置 1-左 2-上 3-右 4-下




    private View popupView;
    private boolean open=false;
    private boolean hasVal=false;


    private TabMenu() {

    }

    /**
     * 描述：创建跳转类型tab
     */
    public static TabMenu buildJumpTab(String name, @DrawableRes int iconResId, int pos) {
        TabMenu tabMenu = new TabMenu();
        tabMenu.type = 0;
        tabMenu.name = name;
        tabMenu.iconResId = iconResId;
        tabMenu.pos = pos;
        return tabMenu;
    }

    /**
     * 描述：创建单序tab
     */
    public static TabMenu buildSingleOrderTab(String name, boolean active) {
        TabMenu tabMenu = new TabMenu();
        tabMenu.type = 1;
        tabMenu.name = name;
        tabMenu.defaultOrder = 1;
        tabMenu.order = active ? 1 : 0;
        return tabMenu;
    }

    /**
     * 描述：创建双序tab
     */
    public static TabMenu buildDoubleOrderTab(String name, boolean isAsc, boolean active) {
        TabMenu tabMenu = new TabMenu();
        tabMenu.type = 2;
        tabMenu.name = name;
        tabMenu.order = active ? (isAsc ? 1 : 2) : 0;
        tabMenu.defaultOrder = isAsc ? 1 : 2;
        return tabMenu;
    }

    /**
     * 描述：创建下拉
     */
    public static TabMenu buildPopupView(String name, View popupView) {
        TabMenu tabMenu = new TabMenu();
        tabMenu.type = 3;
        tabMenu.name = name;
        tabMenu.popupView = popupView;
        return tabMenu;
    }
    public TabMenu setOrder(int order) {
        this.order = order;
        return this;
    }

    public TabMenu setOpen(boolean open) {
        this.open = open;
        return this;
    }
    public TabMenu setHasVal(boolean hasVal) {
        this.hasVal = hasVal;
        return this;
    }

    public int getType() {
        return type;
    }

    public int getOrder() {
        return order;
    }


    public int getDefaultOrder() {
        return defaultOrder;
    }

    public String getName() {
        return name;
    }

    public int getIconResId() {
        return iconResId;
    }

    public int getPos() {
        return pos;
    }

    public View getPopupView() {
        return popupView;
    }

    public boolean isOpen() {
        return open;
    }

    public boolean isHasVal() {
        return hasVal;
    }

}
